/********************************************************************
 * Copyright(c) 2023-2023 Grayson Zheng.
 * File: key_4_by_4.h
 * Description: Header file for 4 by 4 matrix keyboard.
 * Version: 1.0
 * Date: 2023-07-21
 * Author: zhengxinyu13@qq.com
 * ---------- Revision History ----------
 * <version>
 * <date>
 * <author>
 * <desc>
 * Modified to be suitable to the new coding rules in all functions.
 ********************************************************************/

#include "regx52.h"
#include "STC89C5xRC-rdp.h"
#include "datatype.h"
#include "delay.h"

#ifndef __KEY_4_BY_4__
#define __KEY_4_BY_4__

#define KEYBOARD_16			P2
#define KEYBOARD_ZERO		0x7D
#define KEYBOARD_ONE		0xEE
#define KEYBOARD_TWO		0xED
#define KEYBOARD_THREE		0xEB
#define KEYBOARD_FOUR		0xDE
#define KEYBOARD_FIVE		0xDD
#define KEYBOARD_SIX		0xDB
#define KEYBOARD_SEVEN		0xBE
#define KEYBOARD_EIGHT		0xBD
#define KEYBOARD_NINE		0xBB
#define KEYBOARD_ASTERISK	0x7E
#define KEYBOARD_HASH		0x7B
#define KEYBOARD_A			0xE7
#define KEYBOARD_B			0xD7
#define KEYBOARD_C			0xB7
#define KEYBOARD_D			0x77

enum button
{
	KEY_0,
	KEY_1,
	KEY_2,
	KEY_3,
	KEY_4,
	KEY_5,
	KEY_6,
	KEY_7,
	KEY_8,
	KEY_9,
	KEY_ASTERISK,
	KEY_HASH,
	KEY_A,
	KEY_B,
	KEY_C,
	KEY_D,
	KEY_INVALID,
};

uint_8 scan();
uint_8 keyboard_4_by_4();

#endif